package sg.edu.nus.iss.billing.vo.bill;

import java.util.Date;

import sg.edu.nus.iss.billing.common.Util;

/**
 * @author Chee Ann
 *
 */
public class BillDetailVO {

	private String accountNo;
	private Date billDate;
	private Date dueDate;
	private double previousBalance;
	private double paymentMade;
	private double currentCharges;
	private String fileLocation;
	
	public BillDetailVO() {
		
	}
	/*
	 * For BillDAO 
	 * */
	public BillDetailVO(String accountNo, String billDate, String dueDate,
			String previousBalance, String paymentMade, String currentCharges, String fileLocation) {
		setAccountNo(accountNo);
		setBillDate(Util.getDateFromString(billDate));
		setDueDate(Util.getDateFromString(dueDate));
		double balance = 0;
		try {
			balance = Double.parseDouble(previousBalance);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		setPreviousBalance(balance);
		double payment = 0;
		try {
			payment = Double.parseDouble(paymentMade);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		setPaymentMade(payment);
		double charges = 0;
		try {
		  charges = Double.parseDouble(currentCharges);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		setCurrentCharges(charges);
		setFileLocation(fileLocation);
	}
	
	public String serialised() {
		StringBuilder sb = new StringBuilder();
		String delimiter = "^";
		sb.append(accountNo);
		sb.append(delimiter);
		sb.append(Util.getFormattedDate(billDate));
		sb.append(delimiter);
		sb.append(Util.getFormattedDate(dueDate));
		sb.append(delimiter);
		sb.append(previousBalance);
		sb.append(delimiter);
		sb.append(paymentMade);
		sb.append(delimiter);
		sb.append(currentCharges);
		sb.append(delimiter);
		sb.append(fileLocation);
		return sb.toString();
	}
	/**
	 * @return the billDate
	 */
	public Date getBillDate() {
		return billDate;
	}
	/**
	 * @param billDate the billDate to set
	 */
	public void setBillDate(Date billDate) {
		this.billDate = billDate;
	}
	/**
	 * @return the dueDate
	 */
	public Date getDueDate() {
		return dueDate;
	}
	/**
	 * @param dueDate the dueDate to set
	 */
	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}
	/**
	 * @return the previousBalance
	 */
	public double getPreviousBalance() {
		return previousBalance;
	}
	/**
	 * @param previousBalance the previousBalance to set
	 */
	public void setPreviousBalance(double previousBalance) {
		this.previousBalance = previousBalance;
	}
	/**
	 * @return the paymentMade
	 */
	public double getPaymentMade() {
		return paymentMade;
	}
	/**
	 * @param paymentMade the paymentMade to set
	 */
	public void setPaymentMade(double paymentMade) {
		this.paymentMade = paymentMade;
	}
	/**
	 * @return the currentCharges
	 */
	public double getCurrentCharges() {
		return currentCharges;
	}
	/**
	 * @param currentCharges the currentCharges to set
	 */
	public void setCurrentCharges(double currentCharges) {
		this.currentCharges = currentCharges;
	}
	/**
	 * @return the fileLocation
	 */
	public String getFileLocation() {
		return fileLocation;
	}
	/**
	 * @param fileLocation the fileLocation to set
	 */
	public void setFileLocation(String fileLocation) {
		this.fileLocation = fileLocation;
	}
	/**
	 * @return the accountNo
	 */
	public String getAccountNo() {
		return accountNo;
	}
	/**
	 * @param accountNo the accountNo to set
	 */
	public void setAccountNo(String accountNo) {
		this.accountNo = accountNo;
	}
	
}
